package com.itshizhan.itjidancideveloper.controller.webfront;

import com.itshizhan.itjidancideveloper.dao.PersonalWordDao;
import com.itshizhan.itjidancideveloper.models.PersonalWord;
import com.itshizhan.itjidancideveloper.response.Response;
import com.itshizhan.itjidancideveloper.service.PersonalWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("/webfront/personalWord")
public class FrontPersonalWordController {

    @Autowired
    PersonalWordDao personalWordDao;
    @Autowired
    PersonalWordService personalWordService;

    @PostMapping("/add")
    Response<PersonalWord> saveToPersonalWord(@RequestBody PersonalWord personalWord) {
        PersonalWord dbPersonalWord = personalWordDao.save(personalWord);
        return Response.success(dbPersonalWord);
    }

    @GetMapping("/getMyNote")
    Response<PersonalWord> getMyNote(@RequestParam("userId") String userId,
                                     @RequestParam("wordId") String wordId) {
        PersonalWord note = personalWordService.getNote(userId, wordId);
        return Response.success(note);
    }

}
